package com.example.shop.adapter

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.CategoryEntity
import com.example.shop.R
import com.example.shop.utils.GlideUtils

class CateChildAdapter(list: MutableList<CategoryEntity>):BaseQuickAdapter<CategoryEntity,BaseViewHolder>(
    R.layout.item_cate_child,list) {
    var itemId = 14
    override fun convert(holder: BaseViewHolder, item: CategoryEntity) {
        holder.setText(R.id.cate_child_tv,item.category_name)
        GlideUtils.loadImage(context,item.category_icon!!,holder.getView(R.id.cate_child_iv))
        holder.getView<LinearLayout>(R.id.ll_child).background = if(item.id==itemId) ColorDrawable(
            Color.RED) else null
    }
    fun setSelectedItem(id:Int){
        itemId = id
        notifyDataSetChanged()
    }
}